# -*- coding: utf-8 -*-
import pymongo
client = pymongo.MongoClient('47.75.39.50')
client.admin.authenticate("admin321", "dsf::6666,,<<", mechanism='SCRAM-SHA-1')
db = client.city4

data = set()
for y in db.stores.find():
    # for yy in y['area']:
        # print yy
        # import ipdb;ipdb.set_trace()
    if y['area']:
        data.add(y['area'][1].encode("utf8"))

import MySQLdb
db = MySQLdb.connect("127.0.0.1","root","123456789", "shantianjun",charset="utf8")

# 使用cursor()方法获取操作游标
cursor = db.cursor()

# 使用execute方法执行SQL语句
sql = "insert into area (name,level) values (%s,%s)"
ar = [(x,1) for x in data]
# import ipdb;ipdb.set_trace()
cursor.executemany(sql,ar)
cursor.close()
db.commit()
